import 'package:flutter/material.dart';

class UserCenter extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("设置"),
        elevation: 0.0,
      ),
      body: new UserCenterHome(),
    );
  }
}

class UserCenterHome extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new UserCenterState();
  }
}

class UserCenterState extends State {
  @override
  Widget build(BuildContext context) {
    return new ListView(
      children: <Widget>[
        new Stack(
          alignment: AlignmentDirectional.topCenter,
          children: <Widget>[
            new Image.asset(
              "images/setting_background.png",
              width: 600.0,
              height: 150.0,
              fit: BoxFit.cover,
            ),
            new Container(
              margin: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0),
              width: 600.0,
              height: 300.0,
              color: Colors.white,
              child: new Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  new Image.asset(
                    "images/gh.png",
                    width: 70.0,
                    height: 70.0,
                  ),
                  new Container(
                    margin: const EdgeInsets.only(top: 10.0),
                    child: new Text(
                      "李某某",
                      style: new TextStyle(fontSize: 20.0, color: Colors.black),
                    ),
                  )
                ],
              ),
            )
          ],
        ),
        new Container(
          color: Colors.white,
          margin: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0),
          child: new Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: <Widget>[
              new Item("用户资料", Icons.account_box),
              new Item("检测更新", Icons.update),
              new Item("关于", Icons.info),
            ],
          ),
        )
      ],
    );
  }
}

class Item extends StatefulWidget {
  final String title;
  final IconData icon;

  Item(this.title, this.icon);

  @override
  State<StatefulWidget> createState() {
    return new ItemState(title, icon);
  }
}

class ItemState extends State {
  String title;
  IconData icon;

  ItemState(this.title, this.icon);

  @override
  Widget build(BuildContext context) {
    return new Container(
      margin: const EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0),
      child: new Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          new Icon(
            icon,
            color: Colors.lightBlueAccent,
            size: 40.0,
          ),
          new Container(
            margin: const EdgeInsets.only(top: 8.0),
            child: new Text(
              title,
              style: new TextStyle(
                fontSize: 16.0,
                fontWeight: FontWeight.w400,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
